﻿using UnityEngine;
using UnityEngine.UI;
using Vasuleg.Logic.Entity;
using Vasuleg.UIDrive;

namespace Vasuleg.Logic.Control
{
    public class MonsterView : UIDriveMonoBehaviour<MonsterView>
    {
        public virtual Monster MonsterData { get; set; }

        public GameObject Title1;
        protected override void AwakeBinding()
        {
            var text = Title1.GetComponent<Text>();
            Binding(() => text.text).For(() => $"{MonsterData.MaxLife}").SetDefaultValue("默认文本");
            Binding<bool>(Title1.SetActive).For(() => MonsterData.MaxLife > 0);
        }

        private void OnEnable()
        {
            ThisDrive.MonsterData = new Monster
            {
                MaxLife = 0
            };
        }
    }
}